inputfiles="D:\\PyProgram\\MeshCombined.tcl"

# ====================== Output tcl files ====================
outputfiles="D:\\installfiles\\Opnesees\\OpenSeesParallel2.5.0-x64\\OpenSeesParallel2.5.0-x64\\BeamCfix.txt"

# ====================== Input completes =====================
AllNodeList=[]
content=open(inputfiles)
NodeList=[]
SelectedList=[]
for line in content:
    splited=line.split()
    if len(splited)>0:
        if splited[0]=='node':
            NodeList.append([int(splited[1]),float(splited[2]),float(splited[3]),float(splited[4])])
            #Selection Condition
            if abs(float(splited[2]))<1e-5:
                SelectedList.append(int(splited[1]))
            
AllNodeList.append(NodeList)
content.close()
print(SelectedList)
print('Total:',len(SelectedList))

newf=open(outputfiles,'w')
for i in range(0,len(SelectedList)):
    newf.write('fix %d 1 1 1'%SelectedList[i])
    newf.write('\n')

